﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Presentation.Module.Security.Interfaces.Views;
using Presentation.Shell.Interfaces;
using Presentation.Module.Security.Interfaces.ViewModels;

namespace Presentation.Module.Security.Views
{
    /// <summary>
    /// Interaction logic for RoleView.xaml
    /// </summary>
    public partial class RoleView : UserControl, IRoleView
    {
        private IRoleViewModel _roleViewModel;

        public RoleView(IRoleViewModel roleViewModel)
        {
            InitializeComponent();

            this.DataContext = roleViewModel;
            this._roleViewModel = roleViewModel;
            this._roleViewModel.View = this;
        }

        public event ViewExit ViewExit;

        private void Cancel(object sender, System.Windows.RoutedEventArgs e)
        {
            if (this.ViewExit != null)
            {
                this.ViewExit.Invoke();
            }
        }

        private void UpdateControls(object sender, RoutedEventArgs e)
        {
            BindingExpression bindExp = ((ItemsControl)e.OriginalSource).GetBindingExpression(ItemsControl.ItemsSourceProperty);

            bindExp.UpdateSource();
            bindExp.UpdateTarget();
            this.InvalidateVisual();
        }


    }
}
